package com.ruoyi.web.controller.basic;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BasicPushConfig;
import com.ruoyi.system.service.IBasicPushConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 推送配置Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/basicPushConfig")
public class BasicPushConfigController extends BaseController
{
    @Autowired
    private IBasicPushConfigService basicPushConfigService;

    /**
     * 查询推送配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:basicPushConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicPushConfig basicPushConfig)
    {
        startPage();
        List<BasicPushConfig> list = basicPushConfigService.selectBasicPushConfigList(basicPushConfig);
        return getDataTable(list);
    }

    /**
     * 导出推送配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:basicPushConfig:export')")
    @Log(title = "推送配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicPushConfig basicPushConfig)
    {
        List<BasicPushConfig> list = basicPushConfigService.selectBasicPushConfigList(basicPushConfig);
        ExcelUtil<BasicPushConfig> util = new ExcelUtil<BasicPushConfig>(BasicPushConfig.class);
        util.exportExcel(response, list, "推送配置数据");
    }

    /**
     * 获取推送配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:basicPushConfig:query')")
    @GetMapping(value = "/{pushConfigId}")
    public AjaxResult getInfo(@PathVariable("pushConfigId") Long pushConfigId)
    {
        return success(basicPushConfigService.selectBasicPushConfigByPushConfigId(pushConfigId));
    }

    /**
     * 新增推送配置
     */
    @PreAuthorize("@ss.hasPermi('system:basicPushConfig:add')")
    @Log(title = "推送配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicPushConfig basicPushConfig)
    {
        return toAjax(basicPushConfigService.insertBasicPushConfig(basicPushConfig));
    }

    /**
     * 修改推送配置
     */
    @PreAuthorize("@ss.hasPermi('system:basicPushConfig:edit')")
    @Log(title = "推送配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicPushConfig basicPushConfig)
    {
        return toAjax(basicPushConfigService.updateBasicPushConfig(basicPushConfig));
    }

    /**
     * 删除推送配置
     */
    @PreAuthorize("@ss.hasPermi('system:basicPushConfig:remove')")
    @Log(title = "推送配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pushConfigIds}")
    public AjaxResult remove(@PathVariable Long[] pushConfigIds)
    {
        return toAjax(basicPushConfigService.deleteBasicPushConfigByPushConfigIds(pushConfigIds));
    }
}
